<?php

$installer = $this;
$installer->startSetup();


$installer->run("
                DROP TABLE IF EXISTS {$this->getTable('zhishidi_dailydeals/deals')};
                CREATE TABLE `{$installer->getTable('zhishidi_dailydeals/deals')}` (
                    `deal_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
                    `product_id` INT(11) unsigned NOT NULL,
                    `deal_price` DOUBLE NOT NULL,
                    `deal_total` INT(11) NOT NULL,
                    `deal_limit` SMALLINT(5) DEFAULT 0,
                    `deal_created` DATETIME NOT NULL,
                    `deal_from` DATETIME NOT NULL,
                    `deal_to` DATETIME NOT NULL,
                    `deal_ended` DATETIME NULL,
                    `deal_info` TEXT NULL,
                    `deal_status` ENUM('public','hidden') DEFAULT 'public',
                    PRIMARY KEY (`deal_id`),
                    CONSTRAINT FOREIGN KEY (`product_id`) REFERENCES {$this->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
                )ENGINE=InnoDB DEFAULT CHARSET = UTF8;

                DROP TABLE IF EXISTS {$this->getTable('zhishidi_dailydeals/stores')};
                CREATE TABLE `{$installer->getTable('zhishidi_dailydeals/stores')}` (
                    `deal_id` int(11) unsigned NOT NULL,
                    `store_id` smallint(5) unsigned DEFAULT 0)ENGINE=InnoDB DEFAULT CHARSET = UTF8;
                "
);

$installer->endSetup();
?>
